﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using BasicFrameworkDemo.Utility;
using Castle.Windsor;
using Castle.Windsor.Installer;

namespace BasicFrameworkDemo.Web.Controllers
{
    public class CastleControllerUtility
    {
        private static readonly CastleControllerUtility Utility;

        private CastleControllerUtility()
        {
        }

        public static CastleControllerUtility GetInstance()
        {
            if (Utility == null)
            {
                return new CastleControllerUtility();
            }

            return Utility;
        }

        public void BootsContainer()
        {
            var controllerFactory = new WindsorControllerFactory(CastleUtility.GetInstance().Container.Kernel);
            ControllerBuilder.Current.SetControllerFactory(controllerFactory);
        }
    }
}
